<template>
  <scroll class="wrapper">
    <div
      class="menu-list"
      :class="{active: index === currentIndex}"
      v-for="(item,index) in categories"
      :key="item.id"
      @click="itemClick(index)"
    >{{item.title}}</div>
  </scroll>
</template>

<script>
import Scroll from "components/common/scroll/Scroll";

export default {
  name: "TabMenu",
  components: {
    Scroll,
  },
  data() {
    return {
      currentIndex: 0,
    };
  },
  props: {
    categories: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  methods: {
    itemClick(index) {
      this.currentIndex = index;
      this.$emit("selectItem", index);
    },
  },
};
</script>

<style scoped>
.wrapper {
  background-color: #fff;
  height: 100%;
  width: 20%;
  box-sizing: border-box;
}
.menu-list {
  height: 45px;
  line-height: 45px;
  text-align: center;
  font-size: 14px;
}
.active {
  font-weight: 600;
  color: var(--color-high-text);
  background-color: #fff;
  border-left: 3px solid var(--color-high-text);
}
</style>
